﻿namespace Pp.Domain.Mappings
{
    using FluentNHibernate.Mapping;
    using Model;

    public abstract class EntityMap<T> : ClassMap<T> where T : IEntity
    {
        protected const int LONG_TEXT_LENGTH = 4096;
        protected const int TEXT_LENGTH = 255;
        protected const int MAX_LENGTH = 10000;

        private readonly string entityName = typeof(T).Name;


        protected EntityMap()
        {
            if (entityName.Length > 20)
                entityName = entityName.Substring(0, 20);

            Id(x => x.Id)
                .GeneratedBy.GuidComb();

            Map(x => x.CreateDate)
                .Not.Nullable()
                .Not.Update();
            Map(x => x.ModifyDate);

            Cache.ReadWrite();
        }
    }
}